<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('结项审核申请列表')"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">项目编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchNum" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchText" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">项目类型</label>
                <div class="layui-input-inline">
                    <select name="searchType" >
                        <option value="">请选择项目类型</option>
                        <option value="a">新型智库项目</option>
                        <option value="c">省级重大项目</option>
                        <option value="d">省级一般项目</option>
                        <option value="e">省级青年项目</option>
                    </select>
                    <!--                    <input type="text" name="searchType" placeholder="" class="layui-input">-->
                </div>
                <label class="layui-form-label">学科分类</label>
                <div class="layui-input-inline">
<!--                    <input type="text" name="searchSub" placeholder="" class="layui-input">-->
                    <select name="searchSub">
                        <option value="" selected>请选择学科分类</option>
                        <option value="a">马列社科</option>
                        <option value="b">党史党建</option>
                        <option value="c">哲学</option>
                        <option value="d">理论经济</option>
                        <option value="e">应用经济</option>
                        <option value="f">统计学</option>
                        <option value="g">政治学</option>
                        <option value="h">法学</option>
                        <option value="i">社会学</option>
                        <option value="j">民族学</option>
                        <option value="k">中国历史</option>
                        <option value="l">世界历史</option>
                        <option value="m">宗教学</option>
                        <option value="n">中国文学</option>
                        <option value="o">外国文学</option>
                        <option value="p">语言学</option>
                        <option value="q">新闻学与传播学</option>
                        <option value="r">图书馆、情报与文献学</option>
                        <option value="s">体育学</option>
                        <option value="t">管理学</option>
                        <option value="u">人口学</option>
                        <option value="v">国际问题研究</option>
                        <option value="w">考古学</option>
                        <option value="x">教育学</option>
                        <option value="y">艺术学</option>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">负责人</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchMan" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">申报单位</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchIns" placeholder="" class="layui-input">
                </div>
                <div class="layui-input-inline" style="padding-left: 40px">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="finishProject-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="finishProject-table" lay-filter="finishProject-table"></table>
    </div>
</div>
</body>

<script type="text/html" id="finishProject-toolbar">
    <button shiro:hasPermission="gen:finishProject:add" class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
        <i class="layui-icon layui-icon-add-1"></i>
		 新增
    </button>
    <button shiro:hasPermission="gen:finishProject:remove" class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
        <i class="layui-icon layui-icon-delete"></i>
		删除
    </button>
</script>

<script type="text/html" id="finishProject-bar">
    {{# if(d.proState==5){}}
    <button shiro:hasPermission="gen:finishProject:edit" class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit" title="修改"><i class="layui-icon layui-icon-edit"></i>
    </button>
    <button shiro:hasPermission="gen:finishProject:remove" class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove" title="删除"><i class="layui-icon layui-icon-delete"></i>
    </button>
    {{# }else{ }}
    <button shiro:hasPermission="gen:finishProject:edit" class="pear-btn pear-btn-primary pear-btn-sm" lay-event="check" title="查看"><i class="layui-icon layui-icon-file"></i>查看
    </button>
    {{#  } }}

</script>


								
<script type="text/html" id="proType-type">
	

	{{#if (d.proType == 0) { }}
    <span class="layui-badge layui-bg-default-blue">新型智库项目</span>

	{{#if (d.proType == 1) { }}
    <span class="layui-badge layui-bg-default-blue">省级社科规划项目</span>
    {{# } }}
</script>
																																														
<script type="text/html" id="resType-type">
	

	{{#if (d.resType == 0) { }}
    <span class="layui-badge layui-bg-default-blue">出版物</span>

	{{#if (d.resType == 1) { }}
    <span class="layui-badge layui-bg-default-blue">打印稿</span>

	{{#if (d.resType == 2) { }}
    <span class="layui-badge layui-bg-default-blue">手稿或其他复印件</span>

	{{#if (d.resType == 3) { }}
    <span class="layui-badge layui-bg-default-blue">其它</span>
    {{# } }}
</script>
																														
<script type="text/html" id="finishType-type">
	

	{{#if (d.finishType == 0) { }}
    <span class="layui-badge layui-bg-default-blue">正常</span>

	{{#if (d.finishType == 1) { }}
    <span class="layui-badge layui-bg-default-blue">提前</span>

	{{#if (d.finishType == 2) { }}
    <span class="layui-badge layui-bg-default-blue">延期</span>

	{{#if (d.finishType == 3) { }}
    <span class="layui-badge layui-bg-default-blue">免于鉴定</span>

	{{#if (d.finishType == 4) { }}
    <span class="layui-badge layui-bg-default-blue">申请中止或撤销</span>
    {{# } }}
</script>
																																																																																																																																																													
<script type="text/html" id="other1-img">
	 {{#if (d.other1 != null && d.other1 != '') { }}
		<a onclick='view("{{d.other1}}")'>
			{{d.other1}}
			<i class="layui-icon layui-icon-template" lay-filter="other1-view"></i>
    	</a>
	 {{# } else { }}
		-
	 {{# } }}
</script>
							

<script type="text/javascript" th:inline="javascript">
	var proType_list = [[${@dict.getType('pro_type')}]];
	
	var resType_list = [[${@dict.getType('res_type')}]];
	
	var finishType_list = [[${@dict.getType('finish_type')}]];
	
	
	window.selectDictLabel=function(datas, value) {
		var actions = [];
	    $.each(datas, function(index, dict) {
	        if (dict.dictValue == ('' + value)) {
	        	var listClass = ("default"== dict.listClass) ? "" : "badge badge-" + dict.listClass;
	        	actions.push(sprintf("<span class='%s'>%s</span>", listClass, dict.dictLabel));
	            return false;
	        }
	    });
	    return actions.join('');
	}
	window.sprintf=function (str) {
	    var args = arguments, flag = true, i = 1;
	    str = str.replace(/%s/g, function () {
	        var arg = args[i++];
	        if (typeof arg === 'undefined') {
	            flag = false;
	            return '';
	        }
	        return arg;
	    });
	    return flag ? str : '';
	}
</script>	
	


<th:block th:include="include :: footer"/>
<script>
    layui.use(['table', 'form', 'jquery'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let BUCKETURL_PATH='[[${bucketURL}]]';
				
        let MODULE_PATH = rootPath+"/FinishProjectController/";
        let cols = [
            [
               {type: 'checkbox'},

                {title: '序号', type: 'numbers'},

                {title: '状态', field: 'proState', align: 'center',
                    templet:function (d){
                        if(d.proState == 0){
                            return "审核中";
                        }else if(d.proState == 1){
                            return "已结项";
                        }else if(d.proState == 2){
                            return "审核不通过";
                        }else if(d.proState == 5){
                            return "待提交";
                        }
                    }
                },
    	                	
               {title: '项目批准号', field: 'proNumber', align: 'center'},

                {title: '项目名称', field: 'proName', align: 'center'},
    	                	
        	   {title: '项目类型', field: 'proTypeChild', align: 'center',
                       templet:function (d){
                           if(d.proTypeChild == "a"){
                               return "新型智库项目";
                           }else if(d.proTypeChild == "c"){
                               return "省级重大项目";
                           }else if(d.proTypeChild == "d"){
                               return "省级一般项目";
                           }else if(d.proTypeChild == "e"){
                               return "省级青年项目";
                           }
                       }
               },
    	                	
               {title: '学科分类', field: 'proSubject', align: 'center',
                   templet:function (d){
                       if(d.proSubject == "a"){
                           return "马列社科";
                       }else if(d.proSubject == "b"){
                           return "党史党建";
                       }else if(d.proSubject == "c"){
                           return "哲学";
                       }else if(d.proSubject == "d"){
                           return "理论经济";
                       }else if(d.proSubject == "e"){
                           return "应用经济";
                       }else if(d.proSubject == "f"){
                           return "统计学";
                       }else if(d.proSubject == "g"){
                           return "政治学";
                       }else if(d.proSubject == "h"){
                           return "法学";
                       }else if(d.proSubject == "i"){
                           return "社会学";
                       }else if(d.proSubject == "j"){
                           return "民族学";
                       }else if(d.proSubject == "k"){
                           return "中国历史";
                       }else if(d.proSubject == "l"){
                           return "世界历史";
                       }else if(d.proSubject == "m"){
                           return "宗教学";
                       }else if(d.proSubject == "n"){
                           return "中国文学";
                       }else if(d.proSubject == "o"){
                           return "外国文学";
                       }else if(d.proSubject == "p"){
                           return "语言学";
                       }else if(d.proSubject == "q"){
                           return "新闻学与传播学";
                       }else if(d.proSubject == "r"){
                           return "图书馆、情报与文献学";
                       }else if(d.proSubject == "s"){
                           return "体育学";
                       }else if(d.proSubject == "t"){
                           return "管理学";
                       }else if(d.proSubject == "u"){
                           return "人口学";
                       }else if(d.proSubject == "v"){
                           return "国际问题研究";
                       }else if(d.proSubject == "w"){
                           return "考古学";
                       }else if(d.proSubject == "x"){
                           return "教育学";
                       }else if(d.proSubject == "y"){
                           return "艺术学";
                       }
                   }
               },
    	                	
               {title: '承担单位', field: 'proDept', align: 'center'},
    	                	
               {title: '填表时间', field: 'manUpdateTime', align: 'center',
                   templet : "<div>{{layui.util.toDateString(d.manUpdateTime, 'yyyy-MM-dd')}}</div>"},
                    
               {title: '操作', toolbar: '#finishProject-bar', align: 'center',
                   templet: function (d){
                       return d.proState
                   }
               }
            ]
        ]

        //table表单列表
        table.render({
            elem: '#finishProject-table',
            url: MODULE_PATH + 'list',
            page: true,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#finishProject-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports']
        });

        //table图标事件绑定
        table.on('tool(finishProject-table)', function (obj) {
            if (obj.event === 'remove') {
                window.remove(obj);
            } else if (obj.event === 'edit') {
                window.edit(obj);
            }else if (obj.event === 'check') {
                window.check(obj);
            }
        });

        //table工具栏绑定
        table.on('toolbar(finishProject-table)', function (obj) {
            if (obj.event === 'add') {
                window.add();
            } else if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'batchRemove') {
                window.batchRemove(obj);
            }
        });

        //查询按钮绑定
        form.on('submit(finishProject-query)', function (data) {
            table.reload('finishProject-table', {page: {curr: 1}, where: data.field})
            return false;
        });


        //添加
        window.add = function () {
           var index = layer.open({
                type: 2,
                title: '新增',
                shade: 0.1,
                area: ['1305px', '651px'],
                content: MODULE_PATH + 'add',
               //删除未提交的课程参与者信息
               // end: function(data){
               //     $.ajax({
               //         url: MODULE_PATH + 'removeParticipator',
               //         dateType: 'json',
               //         type: 'delete'
               //     })
               // }
            });
           layer.full(index);
        }
        //修改
        window.edit = function (obj) {
            var index = layer.open({
                type: 2,
                title: '修改',
                shade: 0.1,
                area: ['1305px', '651px'],
                content: MODULE_PATH + 'edit/' + obj.data['id']
            });
            layer.full(index);
        }



        //查看
        window.check = function (obj) {
            var index = layer.open({
                type: 2,
                title: '查看',
                shade: 0.1,
                area: ['1305px', '651px'],
                content: MODULE_PATH + 'check/' + obj.data['id']
            });
            layer.full(index);
        }

        //删除
        window.remove = function (obj) {
            layer.confirm('确定要删除该数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + obj.data['id'],
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code==200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                obj.del();
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }

        //批量删除
        window.batchRemove = function (obj) {
            let data = table.checkStatus(obj.config.id).data;
            if (data.length === 0) {
                layer.msg("未选中数据", {icon: 3, time: 1000});
                return false;
            }
            let ids = "";
            for (let i = 0; i < data.length; i++) {
                ids += data[i].id + ",";
            }
            ids = ids.substr(0, ids.length - 1);
            layer.confirm('确定要删除这些数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + ids,
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code==200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                table.reload('finishProject-table');
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }
        
        
		 //查看
        window.view = function (obj) {
            layer.open({
                type: 1,
                title: '查看',
                shade: 0.1,
                area: ['500px', '500px'],
                content: "<img style=\"width:500px\" src=\""+BUCKETURL_PATH+"/"+obj+"\">"
            });
        }
        //刷新按钮
        window.refresh = function () {
            table.reload('finishProject-table');
        }
    })
</script>
</html>